﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Konekcija.Core.Reporting.Dto.Application.Content;

namespace Konekcija.Core.Reporting.Mappings.Content
{
    public class AuctionMap : ClassMap<Auction>
    {
        public AuctionMap()
        {
            Schema("content");
            Table("Auctions");

            Id(x => x.Id).GeneratedBy.GuidComb().Not.Nullable();
            Map(x => x.ItemId).Column("ItemId")
                .Not.Insert().Not.Update().Nullable();
            Map(x => x.Active).Nullable();
            Map(x => x.DateStart).Nullable();
            Map(x => x.DateFinished).Nullable();
            Map(x => x.DateCreated).Nullable();
            Map(x => x.DateChanged).Nullable();
            Map(x => x.ByUserId).Nullable();

            // content
            HasMany(x => x.Biddings)
                .Inverse()
                .AsBag()
                .Key(k => k.Not.Nullable())
                .KeyColumn("AuctionId")
                .Fetch.Join();

            References(x => x.Item).Nullable();
        }
    }
}
